1 00:00:00,720 --> 00:00:01,680 Welcome back. 2 00:00:01,680 --> 00:00:05,130 We're going to go ahead and wrap up the code for our starting menu. 3 00:00:05,130 --> 00:00:06,900 So let's just go ahead and get started. 4 00:00:07,260 --> 00:00:09,480 We're going back into our starting menu handler. 5 00:00:09,480 --> 00:00:12,690 And where we left off was inside of our initialize function. 6 00:00:12,690 --> 00:00:18,060 And we need to fill out the functionality for all of the different buttons that are inside of our GUI. 7 00:00:18,390 --> 00:00:25,140 Basically, what we need to do here is we need to first get all of the servers that currently exist 8 00:00:25,140 --> 00:00:27,720 in this particular lobby that we're in. 9 00:00:27,720 --> 00:00:34,590 So we're going to get all of the current servers by using our server event, and we're going to invoke 10 00:00:34,590 --> 00:00:38,100 the server with the action of. 11 00:00:39,190 --> 00:00:41,830 To get a service. 12 00:00:41,830 --> 00:00:46,660 We're just going to do get servers and it'll return back to us, all of the servers that currently exist 13 00:00:46,660 --> 00:00:51,910 in the game, and we're going to loop through every single one of those servers in current servers. 14 00:00:56,070 --> 00:01:01,350 And what we're going to do is we're just going to create a server frame for this particular server. 15 00:01:01,440 --> 00:01:05,460 And that's all we need to do actually here for the initialize function, because the next section we 16 00:01:05,460 --> 00:01:10,230 need to do is for starting this service. 17 00:01:10,230 --> 00:01:15,450 And the reason why we're going to be connecting all of the functionality for the GUI buttons in this 18 00:01:15,450 --> 00:01:17,580 function, rather than this function. 19 00:01:18,680 --> 00:01:26,030 Is because I want to make sure that all of the event listeners on the server, on the client, have 20 00:01:26,030 --> 00:01:30,950 all been set up from the initialize functions before we allow the player to actually start pressing 21 00:01:30,950 --> 00:01:32,330 buttons within the GUI. 22 00:01:32,360 --> 00:01:37,970 So we're going to do everything within the start function here for connecting functions to different 23 00:01:37,970 --> 00:01:38,960 button events. 24 00:01:39,320 --> 00:01:43,400 So the first button we need to listen to is our main server menu button. 25 00:01:44,180 --> 00:01:46,190 And we're going to listen for when that's clicked. 26 00:01:46,190 --> 00:01:48,740 And all we need to do is connect a function to this. 27 00:01:48,740 --> 00:01:50,750 We're going to play the click sound. 28 00:01:51,340 --> 00:01:53,020 So play click sound. 29 00:01:53,530 --> 00:01:58,600 And since we're trying to go into the server menu, we need to set the visibility for the main frame 30 00:01:58,600 --> 00:02:00,700 to be off or false. 31 00:02:00,700 --> 00:02:04,420 And then the visibility for the server menu needs to be set to true. 32 00:02:04,630 --> 00:02:07,540 The next button we need to listen to is our about button. 33 00:02:07,540 --> 00:02:09,400 So when that is clicked. 34 00:02:10,610 --> 00:02:12,800 Again, we need to play a quick sound. 35 00:02:12,830 --> 00:02:19,730 We need to set the visibility of our main menu to false, and then set the about menu visibility. 36 00:02:20,800 --> 00:02:21,610 To true. 37 00:02:23,710 --> 00:02:27,520 The next button we need to listen to is our about back button. 38 00:02:27,520 --> 00:02:29,350 So we'll do mouse button, one click. 39 00:02:29,350 --> 00:02:30,760 We'll connect a function to that. 40 00:02:30,760 --> 00:02:31,060 Again. 41 00:02:31,060 --> 00:02:32,410 We'll play a click sound. 42 00:02:34,470 --> 00:02:40,740 We'll set the about menu visible to false because again they're getting out of the about menu. 43 00:02:40,740 --> 00:02:44,550 And we're going to set the visibility of the main menu back to true. 44 00:02:44,940 --> 00:02:49,440 Next let's go ahead and start filling out the different functionality for the buttons in the server 45 00:02:49,440 --> 00:02:49,800 menu. 46 00:02:50,100 --> 00:02:56,130 So for example for the server join button, when that is clicked we need to connect a function here. 47 00:02:56,710 --> 00:03:00,040 And we need to first verify that the player has actually selected a server. 48 00:03:00,040 --> 00:03:05,710 So if they have not selected a server, then we're just going to return because we don't want to do 49 00:03:05,710 --> 00:03:06,430 anything. 50 00:03:06,430 --> 00:03:08,950 Otherwise we can play the click sound. 51 00:03:09,960 --> 00:03:13,500 And then we're going to check whether or not the server has a password. 52 00:03:13,500 --> 00:03:17,850 So if selected server get attribute. 53 00:03:19,730 --> 00:03:21,560 Has password. 54 00:03:21,560 --> 00:03:28,460 So if the server has a password, then we're going to set the server menu dot visible to false. 55 00:03:28,460 --> 00:03:33,740 And we're going to set the enter password menu dot visibility to true because they need to enter a password 56 00:03:33,740 --> 00:03:35,000 for this server. 57 00:03:35,240 --> 00:03:38,060 Otherwise if the server doesn't have. 58 00:03:39,450 --> 00:03:41,970 A, um, you know, password. 59 00:03:41,970 --> 00:03:44,040 Then we can call our join server function. 60 00:03:44,640 --> 00:03:49,590 And in fact, we haven't filled out this function yet, so let's go ahead and do that. 61 00:03:50,160 --> 00:03:55,770 So inside of our join server function, what we need to do is we need to use our server event. 62 00:03:55,770 --> 00:04:00,120 And we need to invoke the server that we wish to join a server. 63 00:04:00,120 --> 00:04:04,650 So server action enums two server join server. 64 00:04:04,800 --> 00:04:08,550 And we're going to pass to them the owner of the server that we wish to join. 65 00:04:08,550 --> 00:04:14,820 So owner is equal to selected server get attribute owner. 66 00:04:16,700 --> 00:04:20,810 And this should return back to us a boolean. 67 00:04:22,450 --> 00:04:28,570 A message and then the server itself that we are attempting to join. 68 00:04:28,570 --> 00:04:38,020 Because if you remember, when we wish to add a player to a server and player, let me look real quick. 69 00:04:38,610 --> 00:04:39,180 Right? 70 00:04:39,180 --> 00:04:39,600 Okay. 71 00:04:39,600 --> 00:04:44,850 So when we add a player to a server, we're also going to be returning back to them. 72 00:04:44,850 --> 00:04:47,700 The server object that this player joined. 73 00:04:48,360 --> 00:04:51,300 So we're going to store that in that variable right there. 74 00:04:51,840 --> 00:05:00,600 And if we were successful in joining the server then in server menu dot server name dot text. 75 00:05:01,690 --> 00:05:06,160 Is going to be equal to the server dot owner dot name. 76 00:05:06,250 --> 00:05:10,720 And we're going to concatenate it with apostrophe s server. 77 00:05:10,720 --> 00:05:15,940 So whoever owns the server we're going to display their name inside of the server menu. 78 00:05:17,010 --> 00:05:25,140 And then we're going to loop through every single player in server and ipairs server, dot players in 79 00:05:25,140 --> 00:05:25,890 server. 80 00:05:27,350 --> 00:05:34,190 And we're going to do is we're going to create a player frame for this player that is inside of the 81 00:05:34,190 --> 00:05:34,820 server. 82 00:05:35,470 --> 00:05:40,840 Then we can set the server menu dot visibility equal to false. 83 00:05:41,140 --> 00:05:46,090 We're going to set the enter password menu dot visibility to false just in case it was open. 84 00:05:46,180 --> 00:05:50,350 And then we're going to set the end server menu dot visibility equal to true. 85 00:05:51,160 --> 00:05:55,780 Now inside of this for loop, it's actually going to create a player frame for every single player, 86 00:05:55,780 --> 00:05:56,680 including us. 87 00:05:56,680 --> 00:06:03,400 So if you don't want to have a frame of the local player itself, you could add an if statement here 88 00:06:03,400 --> 00:06:07,660 to check to see if the player in the server is equal to the local player, and you would just continue 89 00:06:07,660 --> 00:06:10,000 looping, but I'm just going to leave it like this. 90 00:06:10,000 --> 00:06:14,440 That way we can see ourselves in the server as well, and then once that's done, we can go ahead and 91 00:06:14,440 --> 00:06:18,430 display the message that is returned back from our invoke server function. 92 00:06:18,430 --> 00:06:23,650 So it'll tell us if we successfully join the server, or it might give us an error message instead. 93 00:06:24,610 --> 00:06:29,920 So let's go ahead and go back down to our start function, because the next button that we're going 94 00:06:29,920 --> 00:06:31,810 to listen to is the create button. 95 00:06:31,810 --> 00:06:35,140 So server create button mouse button one click. 96 00:06:35,140 --> 00:06:37,690 We're going to connect a function to this. 97 00:06:38,680 --> 00:06:40,930 We're going to play a click sound. 98 00:06:42,050 --> 00:06:45,440 And then we're going to do server menu visibility equal to false. 99 00:06:45,440 --> 00:06:49,040 And then we're going to enable the visibility of our create menu. 100 00:06:50,670 --> 00:06:53,130 And then there's a back button in there as well. 101 00:06:53,130 --> 00:06:58,080 So server back button dot mouse button one click connect a function to this. 102 00:06:59,090 --> 00:07:05,390 We're going to set the server menu dot visibility equal to false, and then set the main menu dot visibility 103 00:07:05,390 --> 00:07:06,410 equal to true. 104 00:07:06,410 --> 00:07:09,110 And of course make sure to play a click sound. 105 00:07:10,480 --> 00:07:16,090 Uh, the next section we could do is the buttons when you are inside of the server. 106 00:07:16,090 --> 00:07:21,280 So in server, uh, leave button, which I believe is the only button. 107 00:07:21,790 --> 00:07:24,700 When we click that, we're going to connect a function to it. 108 00:07:25,180 --> 00:07:27,190 We're going to play the click sound. 109 00:07:27,490 --> 00:07:31,660 And what we need to do is we need to invoke to the server to leave a server. 110 00:07:31,660 --> 00:07:37,120 So local success message is going to be equal to server event invoke server. 111 00:07:37,120 --> 00:07:44,110 We're going to pass the action server action enums dot two server dot leave server. 112 00:07:46,070 --> 00:07:53,870 If we were not successful in leaving a server, then we're going to display a message of whatever the 113 00:07:53,870 --> 00:07:54,950 error message is. 114 00:07:56,540 --> 00:07:57,800 Otherwise. 115 00:07:57,800 --> 00:08:03,650 What we could do is set in server menu dot visibility equal to false. 116 00:08:05,670 --> 00:08:09,750 And then set server menu visibility equal to true. 117 00:08:09,990 --> 00:08:15,420 And then we want to clear out the player list inside of our in server menu because we just left it. 118 00:08:16,010 --> 00:08:18,800 So we're going to call our clear player list function. 119 00:08:19,660 --> 00:08:24,730 And I guess that's the next one we can, um, fill out, because I don't believe we filled out this 120 00:08:24,730 --> 00:08:30,520 function yet, so I'm actually going to pass the scrolling frame or the list of players we want to clear 121 00:08:30,520 --> 00:08:30,730 out. 122 00:08:30,730 --> 00:08:35,980 So in server menu dot player list we want to clear out this particular scrolling frame. 123 00:08:35,980 --> 00:08:37,780 So let's go ahead and fill out this function. 124 00:08:38,690 --> 00:08:41,900 So we'll get past a frame to this. 125 00:08:42,790 --> 00:08:48,040 And what we could do is we could loop through every single other, you know, frame or aka text label 126 00:08:48,040 --> 00:08:50,590 in eye pairs frame. 127 00:08:52,290 --> 00:08:53,580 Actually, let me rename this. 128 00:08:53,580 --> 00:08:55,470 We'll call this which frame. 129 00:08:56,070 --> 00:08:58,170 So which frame? 130 00:08:58,170 --> 00:09:00,300 We want to clear out the player list for? 131 00:09:00,780 --> 00:09:07,260 Where we're going to do is we're going to check if this frame in here is a text button which only belongs 132 00:09:07,260 --> 00:09:10,470 to, you know, those different players. 133 00:09:11,100 --> 00:09:14,520 If it is a text button then we're just going to destroy the frame. 134 00:09:15,260 --> 00:09:19,010 And then we're also going to make sure to set selected player. 135 00:09:20,740 --> 00:09:21,790 Equal. 136 00:09:22,960 --> 00:09:24,010 To nil. 137 00:09:24,130 --> 00:09:25,090 Cool. 138 00:09:25,180 --> 00:09:26,440 Seems good. 139 00:09:26,830 --> 00:09:32,230 Now let's go ahead and start filling out the buttons for when we are the owner of a server. 140 00:09:32,230 --> 00:09:34,240 So in owner menu. 141 00:09:34,960 --> 00:09:38,350 Uh, let's do the remove player button. 142 00:09:38,590 --> 00:09:44,590 So when we click that, what we're going to do is check if we have a selected player. 143 00:09:44,590 --> 00:09:50,200 So if we do not have a selected player selected player then we're just going to return because we don't 144 00:09:50,200 --> 00:09:50,800 care. 145 00:09:50,950 --> 00:09:53,410 Otherwise we're going to play the click sound. 146 00:09:53,500 --> 00:09:56,860 And then we're going to request to the server to remove a player. 147 00:09:56,860 --> 00:10:01,420 So success message is going to be equal to the server event. 148 00:10:01,420 --> 00:10:06,580 We're going to invoke to the server with the action of. 149 00:10:08,570 --> 00:10:11,990 Remove player and the player we wish to remove. 150 00:10:13,280 --> 00:10:17,540 Uh, we'll just call it player to remove because I believe that is the key value pair we use. 151 00:10:17,540 --> 00:10:19,880 So player to remove. 152 00:10:19,910 --> 00:10:20,480 Yeah. 153 00:10:20,480 --> 00:10:21,800 So that's the key value pair. 154 00:10:21,800 --> 00:10:24,800 We need to fulfill the player to remove key value pair. 155 00:10:25,040 --> 00:10:30,500 So the player to remove is going to be equal to selected player. 156 00:10:33,090 --> 00:10:37,770 And we're going to get the attribute on this text button of owner. 157 00:10:37,770 --> 00:10:42,240 So we're passing the name to the server of the player we wish to remove. 158 00:10:42,510 --> 00:10:49,440 And then once that is done, we can go ahead and display a message based on what is ever returned from 159 00:10:49,440 --> 00:10:50,970 our remote function. 160 00:10:51,610 --> 00:10:52,000 All right. 161 00:10:52,000 --> 00:10:57,430 The next button we need to listen to is the in owner delete button. 162 00:10:57,430 --> 00:11:00,820 Let's say the owner wants to delete the server. 163 00:11:00,820 --> 00:11:03,730 So we're going to listen for when that is clicked. 164 00:11:04,890 --> 00:11:08,460 And what we're going to do here is we're going to play a quick sound. 165 00:11:09,190 --> 00:11:11,920 And we're going to again invoke to the server. 166 00:11:11,920 --> 00:11:22,450 So server event invoke server with the action of two server dot destroy or delete server. 167 00:11:22,930 --> 00:11:28,780 And then if we are successful then what we could do is we could set currently owning server equal to 168 00:11:28,780 --> 00:11:29,680 false. 169 00:11:29,980 --> 00:11:33,430 We're going to set in owner menu dot visibility equal to false. 170 00:11:33,430 --> 00:11:36,700 And then server menu dot visibility is going to be set to true. 171 00:11:37,430 --> 00:11:42,890 And we're also going to clear out the player list inside of the inn owner menu player list. 172 00:11:42,890 --> 00:11:47,630 And then at the very end, we can go ahead and display the message that gets returned from our remote 173 00:11:47,630 --> 00:11:48,260 function. 174 00:11:49,530 --> 00:11:53,280 Another button we need to listen to is the end owner start button. 175 00:11:54,510 --> 00:11:57,510 So when that is clicked, we'll connect a function to this as well. 176 00:11:58,470 --> 00:12:00,240 We'll play the click sound. 177 00:12:00,930 --> 00:12:11,310 And what we could do here is we could use our server event and invoke to the server that we wish to 178 00:12:11,310 --> 00:12:11,940 start the game. 179 00:12:11,940 --> 00:12:13,380 So server. 180 00:12:14,850 --> 00:12:15,360 Action. 181 00:12:15,360 --> 00:12:17,790 Enums dot two server. 182 00:12:18,610 --> 00:12:22,180 Dot start game or start server. 183 00:12:23,430 --> 00:12:25,800 We'll get the success. 184 00:12:26,690 --> 00:12:30,170 And potential message from this if there is one. 185 00:12:30,170 --> 00:12:33,860 And actually, I'm not worried about a message from this because we're just going to be starting the 186 00:12:33,860 --> 00:12:34,580 server. 187 00:12:34,970 --> 00:12:35,450 Okay. 188 00:12:35,450 --> 00:12:40,340 The next buttons we need to listen to is when we want to create a server. 189 00:12:40,340 --> 00:12:42,830 So when we are in the create menu. 190 00:12:42,830 --> 00:12:48,350 So create button dot mouse button click we're going to connect a function to this. 191 00:12:48,350 --> 00:12:50,630 We're going to play the click sound. 192 00:12:50,630 --> 00:12:54,950 And this is when we've fulfilled all of the settings. 193 00:12:54,950 --> 00:13:00,980 And we need to go ahead and tell the server that we want to, you know, create our own custom server. 194 00:13:00,980 --> 00:13:03,170 So I'm going to create a table called data. 195 00:13:03,910 --> 00:13:07,690 And here it's going to store whether or not the server has a password. 196 00:13:08,540 --> 00:13:11,660 So we'll set that equal to is password on. 197 00:13:12,410 --> 00:13:14,630 We'll store the password in here as well. 198 00:13:14,630 --> 00:13:19,700 So password input menu dot text box dot text. 199 00:13:21,610 --> 00:13:28,720 And then max size, we're going to set using a function called two number. 200 00:13:28,720 --> 00:13:32,170 And we're going to convert inside of our server size menu. 201 00:13:33,010 --> 00:13:37,150 We're going to get the number text label and get the text in there, and we're going to convert that 202 00:13:37,150 --> 00:13:39,340 to a number to represent the max size. 203 00:13:40,680 --> 00:13:44,430 And we're going to use our server event to invoke to the server. 204 00:13:45,380 --> 00:13:48,560 That we wish to create a server. 205 00:13:48,560 --> 00:13:51,920 So create server and then we're going to pass this data. 206 00:13:52,720 --> 00:13:58,210 And we're going to store the success and then the message from the server. 207 00:13:58,210 --> 00:14:03,430 So if we were successful in creating a server, then we're going to set currently owning server equal 208 00:14:03,430 --> 00:14:04,420 to true. 209 00:14:05,030 --> 00:14:08,570 We're going to set the create menu dot visibility equal to false. 210 00:14:08,570 --> 00:14:13,070 And then we're going to enable in our menu that visible equal to true. 211 00:14:13,490 --> 00:14:19,640 And then we're going to display a message of whatever is returned from our server event. 212 00:14:19,640 --> 00:14:23,450 So let me go ahead and verify that the data we're passing here is correct. 213 00:14:23,450 --> 00:14:27,680 So if we go to our server service when we wish to create a server. 214 00:14:29,120 --> 00:14:29,570 Yeah. 215 00:14:29,570 --> 00:14:31,850 We're going to have the password. 216 00:14:32,410 --> 00:14:38,680 Or the boolean of whether or not we have a password, the password itself, as well as the max size 217 00:14:38,680 --> 00:14:39,730 for the server. 218 00:14:40,810 --> 00:14:41,350 Okay. 219 00:14:41,350 --> 00:14:42,160 Looks good. 220 00:14:42,790 --> 00:14:47,500 The next button we can listen to is the Create Cancel button. 221 00:14:47,500 --> 00:14:52,150 So when we are in the create menu, if we don't want to create a server, we change our mind. 222 00:14:52,570 --> 00:14:54,910 Then we're going to play a click sound. 223 00:14:54,910 --> 00:14:58,510 We're going to set create menu dot visibility equal to false. 224 00:14:58,750 --> 00:15:02,800 And then we're going to set the server menu dot visibility equal to true. 225 00:15:04,210 --> 00:15:08,050 And then we need to listen to that toggle button for the password. 226 00:15:08,050 --> 00:15:09,310 So we'll call it create. 227 00:15:10,510 --> 00:15:13,960 Password toggle button will listen for when that is clicked. 228 00:15:14,620 --> 00:15:17,860 So when that is clicked, we're going to play the click sound. 229 00:15:18,190 --> 00:15:20,890 And we're going to check if password is on. 230 00:15:20,890 --> 00:15:25,630 So if is password on then we're going to say is password on. 231 00:15:25,630 --> 00:15:26,440 Back to false. 232 00:15:26,440 --> 00:15:28,900 So let's say you know they toggle it back off. 233 00:15:28,900 --> 00:15:32,440 We're going to set password toggle menu. 234 00:15:33,580 --> 00:15:37,990 And we're going to set the fill in there. 235 00:15:38,020 --> 00:15:40,270 The visibility of that to false. 236 00:15:40,270 --> 00:15:46,570 And then we're going to set the password input menu dot visibility to false as well. 237 00:15:46,570 --> 00:15:51,850 So if we go to our create server menu. 238 00:15:51,850 --> 00:15:54,340 So let me enable the visibility here. 239 00:15:54,340 --> 00:15:56,020 Disable the visibility of this one. 240 00:15:56,560 --> 00:15:58,720 So when we click this here. 241 00:16:00,100 --> 00:16:01,630 Um, let's go ahead and find it. 242 00:16:01,630 --> 00:16:03,550 It is. 243 00:16:08,810 --> 00:16:09,110 Yeah. 244 00:16:09,110 --> 00:16:10,310 This password toggle here. 245 00:16:10,310 --> 00:16:11,450 There's a fill in here. 246 00:16:11,450 --> 00:16:13,280 So when that's enabled. 247 00:16:14,410 --> 00:16:15,400 It'll fill in. 248 00:16:15,430 --> 00:16:19,510 You know this to show that we have enabled the password. 249 00:16:19,510 --> 00:16:24,670 And then it'll go ahead and put in that password input down here. 250 00:16:24,670 --> 00:16:29,560 And then if we toggle it back off, it'll make this disappear and turn the fill back off. 251 00:16:30,460 --> 00:16:34,630 If the password has not been turned on, then we're going to set its password on to true. 252 00:16:34,660 --> 00:16:46,240 Set password toggle menu dot fill dot visible equal to true and then password input menu dot visibility 253 00:16:46,240 --> 00:16:48,100 equal to true as well. 254 00:16:48,730 --> 00:16:49,330 Okay. 255 00:16:49,330 --> 00:16:52,600 The next button we need to listen to is the create server. 256 00:16:53,750 --> 00:16:57,140 Um, I believe it is the size or what is it? 257 00:16:57,140 --> 00:16:58,730 It's create. 258 00:16:59,600 --> 00:17:00,950 We find it increase. 259 00:17:00,950 --> 00:17:01,160 Yeah. 260 00:17:01,160 --> 00:17:04,310 So let's do or let's do the decrease button first. 261 00:17:04,670 --> 00:17:08,390 So when that is clicked we're going to connect a function to that. 262 00:17:08,840 --> 00:17:10,490 We're going to play the click sound. 263 00:17:10,490 --> 00:17:15,620 We're going to create a variable I'm going to call it uh new number. 264 00:17:15,620 --> 00:17:19,040 So this is the new number we want to set the server size to. 265 00:17:19,070 --> 00:17:26,780 So we're going to do two number server size menu dot number dot text. 266 00:17:26,780 --> 00:17:28,910 So we get that as a number. 267 00:17:29,270 --> 00:17:33,650 And then we're going to subtract it by one because we're decreasing it here. 268 00:17:34,580 --> 00:17:43,070 If this new number is less than the minimum server size then new number is going to be equal to min 269 00:17:43,070 --> 00:17:44,300 server size. 270 00:17:45,870 --> 00:17:51,960 And we're going to set server size menu dot number dot text equal to this new number. 271 00:17:52,790 --> 00:17:57,410 Now, if you don't want to use an if statement here, you could also use Math.max. 272 00:17:57,410 --> 00:18:06,290 So we could set new num equal to math dot max and pass new num and then minimum server size. 273 00:18:06,290 --> 00:18:09,560 So let's say they somehow make new numbers zero. 274 00:18:09,590 --> 00:18:11,180 Minimum server size is one. 275 00:18:11,180 --> 00:18:13,970 So that's the greater number out of these two numbers. 276 00:18:13,970 --> 00:18:16,160 So it'll return one back to Newnham. 277 00:18:16,160 --> 00:18:20,270 And we'll set that as the number inside of this text label. 278 00:18:21,100 --> 00:18:23,380 And then we could do the same thing for the increase button. 279 00:18:23,380 --> 00:18:25,900 So create increase button mouse button one. 280 00:18:25,900 --> 00:18:27,580 Click connect a function. 281 00:18:27,790 --> 00:18:36,820 Play a click sound local new number is going to be equal to two string server size menu dot number dot 282 00:18:36,820 --> 00:18:38,770 text subtract it. 283 00:18:38,770 --> 00:18:41,260 Or actually we're going to add one. 284 00:18:42,070 --> 00:18:48,010 And then we can set new num equal to math dot minimum. 285 00:18:48,010 --> 00:18:50,170 So we're going to pass a new num. 286 00:18:51,530 --> 00:18:54,350 And then max server size. 287 00:18:54,350 --> 00:18:59,960 So if they accidentally go above the max server size, this will be the smaller number out of the two. 288 00:18:59,960 --> 00:19:01,820 And we'll set new num to that. 289 00:19:02,450 --> 00:19:09,590 And then we can set server size menu dot number dot text equal to new num. 290 00:19:10,230 --> 00:19:10,800 All right. 291 00:19:10,800 --> 00:19:12,180 We're almost done here. 292 00:19:12,750 --> 00:19:16,320 We need to listen to that okay button in our message menu. 293 00:19:16,320 --> 00:19:17,850 So message menu okay. 294 00:19:17,850 --> 00:19:20,520 Button when that is clicked. 295 00:19:21,350 --> 00:19:25,760 You need to apply the click sound, and then we can just set the message menu dot visibility equal to 296 00:19:25,760 --> 00:19:26,570 false. 297 00:19:27,520 --> 00:19:36,130 And then, uh, we can lastly, listen to our, um, password input menu. 298 00:19:36,130 --> 00:19:38,710 So let me disable visibility here. 299 00:19:38,950 --> 00:19:42,970 So when this menu is in here we have two buttons we need to listen to. 300 00:19:43,150 --> 00:19:46,930 So enter password. 301 00:19:47,290 --> 00:19:49,450 Uh let's first listen to the submit button. 302 00:19:49,450 --> 00:19:51,220 So when that is clicked. 303 00:19:52,650 --> 00:19:57,450 Uh, we need to invoke to the server using our server event that we want to submit a password. 304 00:19:57,450 --> 00:20:03,630 So server action enums dot two server dot submit password. 305 00:20:03,630 --> 00:20:09,420 And the owner of the server we wish to submit this password to is going to be owner is equal to selected 306 00:20:09,420 --> 00:20:10,560 server. 307 00:20:10,830 --> 00:20:13,050 Get attribute owner. 308 00:20:15,850 --> 00:20:20,590 And then what was the other key value pair we needed to do so if we had submit password. 309 00:20:22,920 --> 00:20:23,100 Right. 310 00:20:23,100 --> 00:20:26,640 We have our owner and then. 311 00:20:26,640 --> 00:20:36,060 Ah, yes, we need to fulfill a key value pair of submitted password so we can set submitted password. 312 00:20:37,390 --> 00:20:38,500 Equal two. 313 00:20:38,650 --> 00:20:44,170 Enter password menu dot textbox dot text. 314 00:20:45,910 --> 00:20:52,420 We also need to play the click sound for when that is clicked, and then we can get the success and 315 00:20:52,420 --> 00:20:54,580 then the message from the server. 316 00:20:55,960 --> 00:21:02,380 If we were successful, then we can go ahead and join this server because we are now, or we should 317 00:21:02,380 --> 00:21:04,990 be within the whitelist of this particular server. 318 00:21:05,110 --> 00:21:09,730 And then we're just going to display a message of whatever is returned from the server. 319 00:21:11,830 --> 00:21:19,510 The last button we need to fill out for I believe is the enter password menu back button. 320 00:21:19,570 --> 00:21:25,000 So when we click that bad boy again, we need to play a click sound. 321 00:21:26,630 --> 00:21:32,090 We need to set the enter password menu visibility equal to false, and then set the server menu visibility 322 00:21:32,090 --> 00:21:33,410 equal to true. 323 00:21:34,810 --> 00:21:35,650 And you know what? 324 00:21:35,650 --> 00:21:38,740 I think that is all. 325 00:21:39,420 --> 00:21:42,150 So we've gotten all of the stuff filled out. 326 00:21:42,150 --> 00:21:42,600 You know what? 327 00:21:42,600 --> 00:21:44,670 Let's actually do a quick test. 328 00:21:44,670 --> 00:21:45,300 Why not? 329 00:21:45,300 --> 00:21:49,290 So let's go ahead and put this, uh, starting menu back to its default. 330 00:21:49,290 --> 00:21:52,560 So I believe only the main frame is visible. 331 00:21:53,040 --> 00:21:55,860 And we can go ahead and go to the test and hit play. 332 00:21:57,210 --> 00:22:00,510 Any errors we should see show up inside of the console. 333 00:22:01,110 --> 00:22:02,820 So let's go ahead and see. 334 00:22:03,720 --> 00:22:05,940 So we did load the server service. 335 00:22:05,940 --> 00:22:06,360 That's good. 336 00:22:06,360 --> 00:22:07,830 And we initialized it. 337 00:22:08,010 --> 00:22:09,030 Very good. 338 00:22:10,510 --> 00:22:16,090 If we look on the client here, if we load. 339 00:22:16,090 --> 00:22:16,360 Yep. 340 00:22:16,360 --> 00:22:18,100 Looks like we initialize the starting menu. 341 00:22:18,100 --> 00:22:19,060 That's awesome. 342 00:22:19,450 --> 00:22:23,470 Oh, it looks like we forgot to get rid of that print statement within our camera manipulation. 343 00:22:23,470 --> 00:22:24,580 We'll fix that later. 344 00:22:25,360 --> 00:22:32,080 But anyways, now that we're inside of the server menu, we should be able to click the about button. 345 00:22:33,150 --> 00:22:34,350 We got a click. 346 00:22:35,670 --> 00:22:36,900 We can hit back. 347 00:22:36,900 --> 00:22:37,800 Boom, we're back here. 348 00:22:37,800 --> 00:22:39,630 We can go ahead and hit servers. 349 00:22:39,630 --> 00:22:41,220 We are in the server menu. 350 00:22:41,400 --> 00:22:43,410 We can go ahead and hit back as well. 351 00:22:43,530 --> 00:22:45,480 So let's go ahead and create a server. 352 00:22:46,140 --> 00:22:46,590 Perfect. 353 00:22:46,590 --> 00:22:47,280 That's worked. 354 00:22:47,280 --> 00:22:48,480 Can we increase. 355 00:22:48,660 --> 00:22:49,710 Yes we can. 356 00:22:56,930 --> 00:22:57,230 All right. 357 00:22:57,230 --> 00:22:59,390 We're constrained between 1 and 10. 358 00:22:59,870 --> 00:23:01,220 Can I enable a password? 359 00:23:01,220 --> 00:23:01,610 Yep. 360 00:23:01,610 --> 00:23:04,250 And then I can type in a password here like hello. 361 00:23:05,090 --> 00:23:07,190 And then we can hit create server. 362 00:23:07,790 --> 00:23:08,330 There we go. 363 00:23:08,330 --> 00:23:10,520 We got a message server created. 364 00:23:10,520 --> 00:23:11,600 We can hit okay. 365 00:23:11,600 --> 00:23:12,770 And that closes out. 366 00:23:12,770 --> 00:23:14,870 And now we are inside of our server. 367 00:23:14,870 --> 00:23:16,490 We can delete the server. 368 00:23:17,710 --> 00:23:20,590 The server was deleted, but it looks like we did get an error. 369 00:23:20,590 --> 00:23:25,570 So invalid argument number one to Ipairs table expected got instance. 370 00:23:25,570 --> 00:23:26,350 So. 371 00:23:27,230 --> 00:23:30,080 Oh gosh, this is printing like crazy. 372 00:23:30,080 --> 00:23:32,030 So let me go ahead and try to get to it. 373 00:23:33,440 --> 00:23:34,460 Okay, let me get. 374 00:23:34,460 --> 00:23:34,910 Let me go. 375 00:23:34,910 --> 00:23:35,420 Here. 376 00:23:37,100 --> 00:23:40,580 Okay, so where is our error at? 377 00:23:41,360 --> 00:23:43,280 Invalid argument to Ipairs table. 378 00:23:43,280 --> 00:23:45,080 Expected got instance. 379 00:23:45,350 --> 00:23:46,310 Oh, okay. 380 00:23:46,640 --> 00:23:53,240 We forgot to use a getchildren here within our starting menu handler, so let's fix that. 381 00:23:53,990 --> 00:23:55,970 Let's we'll save those changes. 382 00:23:55,970 --> 00:23:58,130 So inside of our clear players function. 383 00:23:58,930 --> 00:24:02,980 We need to make sure to put get children here instead of passing the instance itself. 384 00:24:03,160 --> 00:24:06,310 And actually let me go back to our camera manipulation handler. 385 00:24:07,710 --> 00:24:10,380 And let me find that little goofy print statement here. 386 00:24:10,380 --> 00:24:13,050 It is going to get rid of that bad boy. 387 00:24:13,200 --> 00:24:14,250 No more of that. 388 00:24:14,250 --> 00:24:15,270 We don't need it. 389 00:24:16,360 --> 00:24:18,400 And let's go ahead and test this out again. 390 00:24:22,240 --> 00:24:22,810 All right. 391 00:24:23,260 --> 00:24:24,250 Create a server. 392 00:24:25,990 --> 00:24:27,730 Enter a password, blah blah blah. 393 00:24:27,730 --> 00:24:29,440 Hit create server created. 394 00:24:29,440 --> 00:24:29,980 That's good. 395 00:24:29,980 --> 00:24:31,030 Can we delete it? 396 00:24:31,270 --> 00:24:32,260 Yes we can. 397 00:24:32,260 --> 00:24:33,160 Server deleted. 398 00:24:33,160 --> 00:24:38,740 There is nothing in our server menu and so far actually everything's looking good. 399 00:24:38,740 --> 00:24:42,130 So if I hit start game perfect our teleporting menu shows up. 400 00:24:42,250 --> 00:24:47,350 And of course we're going to get this Http 403 forbidden error in here because we're not allowed to 401 00:24:47,350 --> 00:24:52,600 use the teleport service while we're in studio, but at least we know that's working, so that's nice. 402 00:24:53,270 --> 00:24:59,630 So to actually get this fully tested out here, we're going to launch a local server with three players 403 00:24:59,630 --> 00:25:00,140 here. 404 00:25:01,670 --> 00:25:04,910 Okay, here we are with our three player server. 405 00:25:06,410 --> 00:25:12,830 So what I'm going to do is we're going to check to make sure that a server actually appears within the 406 00:25:12,830 --> 00:25:14,390 uh, within our server menu. 407 00:25:14,390 --> 00:25:19,880 So if I create a server here and let's say I make the size like three, if I hit create, we get server 408 00:25:19,880 --> 00:25:20,510 created. 409 00:25:20,510 --> 00:25:25,220 And then as you can see over here, we get our server added to our other clients. 410 00:25:25,220 --> 00:25:27,830 And of course we can select this server. 411 00:25:27,830 --> 00:25:30,980 We get a red highlight over it and we're allowed to join the server. 412 00:25:30,980 --> 00:25:34,850 So if I hit join it'll tell us we have joined the server. 413 00:25:35,060 --> 00:25:37,970 And as you can see it updated the player count over here as well. 414 00:25:37,970 --> 00:25:40,460 And now we can see both of our players are in here. 415 00:25:40,850 --> 00:25:43,700 And I can see the other player that is inside of my server. 416 00:25:43,700 --> 00:25:47,360 And I can select this player and I can remove them. 417 00:25:47,360 --> 00:25:51,890 So it says player removed and it will tell them you have been kicked from the server. 418 00:25:52,340 --> 00:25:54,800 And it updated the player count as well. 419 00:25:54,800 --> 00:25:56,660 But I can go ahead and join back. 420 00:25:57,380 --> 00:25:58,970 I can remove this player again. 421 00:25:58,970 --> 00:26:01,850 As you can see, it's updating the color. 422 00:26:01,850 --> 00:26:06,170 Now if I keep this server selected and I go and delete the server, there we go. 423 00:26:06,170 --> 00:26:08,030 Our buttons get grayed out. 424 00:26:08,030 --> 00:26:08,990 Very nice. 425 00:26:09,890 --> 00:26:11,900 Let me go ahead and create a server with a password. 426 00:26:11,900 --> 00:26:14,810 So I'll just do 1234 create. 427 00:26:15,470 --> 00:26:19,310 Now if I try to join the server we're going to get into the enter password menu. 428 00:26:19,310 --> 00:26:22,910 And I can type in some password like hello. 429 00:26:22,940 --> 00:26:26,630 If I hit submit it'll tell me password was incorrect. 430 00:26:27,530 --> 00:26:34,460 But I can go ahead and type something in like one, two three, four and hit submit and it'll get success. 431 00:26:34,460 --> 00:26:39,560 And now we are inside of the server player one server and they showed up here as well. 432 00:26:39,560 --> 00:26:44,450 And if I go ahead and hit remove player player removed try to join the server again. 433 00:26:45,770 --> 00:26:50,090 I can type in whatever I want, but password was incorrect. 434 00:26:50,120 --> 00:26:52,070 I'll have to resubmit the password. 435 00:26:52,070 --> 00:26:54,020 And now I'm back inside of the server. 436 00:26:54,530 --> 00:26:59,240 And if I hit start game, GUI gets faded out for those two players. 437 00:26:59,240 --> 00:27:00,080 Very cool. 438 00:27:00,080 --> 00:27:02,900 But it doesn't get faded out on this guy over here. 439 00:27:02,900 --> 00:27:07,550 If I try to join the server and I enter in the correct password. 440 00:27:09,760 --> 00:27:11,740 Actually, we are getting a success message. 441 00:27:11,740 --> 00:27:12,790 That is interesting. 442 00:27:14,380 --> 00:27:16,390 So when the server is locked. 443 00:27:16,390 --> 00:27:20,380 Instead, we should tell this player that you know, the server locked. 444 00:27:20,410 --> 00:27:24,940 Oh, hey, at least our teleport timeout works, so that's neat too. 445 00:27:25,660 --> 00:27:27,940 So let's go ahead and make a change to that as well. 446 00:27:29,100 --> 00:27:33,390 Let's see here we're invoking to the server to join a server. 447 00:27:33,900 --> 00:27:37,080 Let's go to the server service and look for join server. 448 00:27:37,260 --> 00:27:37,860 Here we are. 449 00:27:39,390 --> 00:27:43,650 So we'll get success and result from server to join ad player. 450 00:27:43,650 --> 00:27:46,050 So if we go to our ad player function. 451 00:27:49,190 --> 00:27:50,000 Try to find it here. 452 00:27:50,000 --> 00:27:50,840 Here we go. 453 00:27:51,230 --> 00:27:52,700 It should be returning. 454 00:27:52,700 --> 00:27:54,110 Server is locked. 455 00:27:54,140 --> 00:27:55,070 Oh, you know what? 456 00:27:55,070 --> 00:28:01,310 We forgot to call our, um, lock and unlock function on a particular server. 457 00:28:01,310 --> 00:28:07,700 So when we want to start the game, we need to actually lock the server. 458 00:28:07,700 --> 00:28:13,670 So we're going to do, uh, self lock. 459 00:28:15,120 --> 00:28:17,880 That's why it wasn't showing the correct message. 460 00:28:19,070 --> 00:28:19,640 Otherwise. 461 00:28:19,640 --> 00:28:23,090 That is our server menu basically complete. 462 00:28:23,090 --> 00:28:27,350 All we need to do now is fill out the other services on the server and the client. 463 00:28:27,350 --> 00:28:29,330 So I'll go ahead and see in the next lectures.